//
//  UIView+Message.m
//  message
//
//  Created by runone01 on 16/9/23.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "UIView+Message.h"
#import "UIColor+Addition.h"
@implementation UIView (Message)
-(void)prompt:(NSString *)PromptMessage
{
    
    UILabel * tipLabel = [[UILabel alloc] init];
    tipLabel.numberOfLines=0;
    // 设置提示内容
    [tipLabel setText:PromptMessage];
    tipLabel.backgroundColor = [UIColor grayColor];
   // tipLabel.layer.cornerRadius = 5;
    tipLabel.layer.masksToBounds = YES;
    tipLabel.textAlignment = NSTextAlignmentCenter;
    tipLabel.textColor = [UIColor whiteColor];
    CGSize max=CGSizeMake(self.frame.size.width-30, 9999);
    CGSize newsize=[tipLabel sizeThatFits:max];
    tipLabel.frame=CGRectMake(0, 0, newsize.width, newsize.height);
    [self addSubview:tipLabel];
    // 设置时间和动画效果
    [UIView animateWithDuration:1.5 animations:^{
        tipLabel.alpha = 0.0;
    } completion:^(BOOL finished) {
        // 动画完毕从父视图移除
        [tipLabel removeFromSuperview];
    }];
    
}


-(void)DeviceMessage:(NSString *)deviceMessage
{
    UILabel * tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 230, self.frame.size.width-100, 130)];
    // 设置提示内容
    [tipLabel setText:deviceMessage];
    tipLabel.numberOfLines=0;
    tipLabel.backgroundColor = [UIColor grayColor];
    tipLabel.layer.cornerRadius = 5;
    tipLabel.layer.masksToBounds = YES;
    tipLabel.textAlignment = NSTextAlignmentCenter;
    tipLabel.textColor = [UIColor whiteColor];
//    CGSize max=CGSizeMake(self.frame.size.width, 9999);
//    CGSize newsize=[tipLabel sizeThatFits:max];
//    tipLabel.frame=CGRectMake(0, 0, newsize.width, newsize.height);
    [self addSubview:tipLabel];

}

-(void)DeviceMessageBackGround:(NSString *)BoardMessage

{
    UILabel * tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 230, self.frame.size.width-100, 130)];
    // 设置提示内容
    [tipLabel setText:BoardMessage];
    tipLabel.numberOfLines=0;
    tipLabel.backgroundColor = [UIColor lightGrayColor];
    tipLabel.layer.cornerRadius = 5;
    tipLabel.layer.masksToBounds = YES;
    tipLabel.textAlignment = NSTextAlignmentCenter;
    tipLabel.textColor = [UIColor blackColor];
    //    CGSize max=CGSizeMake(self.frame.size.width, 9999);
    //    CGSize newsize=[tipLabel sizeThatFits:max];
    //    tipLabel.frame=CGRectMake(0, 0, newsize.width, newsize.height);
    [self addSubview:tipLabel];
}

-(void)promptRepoteResult:(NSString *)reportResult ResultButton:(UIButton *)btn
{
    UILabel *tipLabel=[[UILabel alloc] initWithFrame:CGRectMake(40, self.frame.size.height/2-30, self.frame.size.width-80, 30)];
    [tipLabel setText:reportResult];
    tipLabel.backgroundColor = [UIColor grayColor];
    tipLabel.layer.cornerRadius = 5;
    tipLabel.layer.masksToBounds = YES;
    tipLabel.textAlignment = NSTextAlignmentCenter;
    tipLabel.textColor = [UIColor whiteColor];
    [self addSubview:tipLabel];
    
    btn=[[UIButton alloc] initWithFrame:CGRectMake(40, self.frame.size.height/2, self.frame.size.width-80, 30)];
    btn.backgroundColor=[UIColor greenColor];
    [self addSubview:btn];
    
}
@end
